package cn.zd.demo1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class DrawableActivity extends AppCompatActivity implements View.OnClickListener {

    private View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Toast.makeText(this,this.getClass().getName(),Toast.LENGTH_LONG).show();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawable);
        view = findViewById(R.id.v_content);
        findViewById(R.id.btn_cy).setOnClickListener(this);
        findViewById(R.id.btn_sq).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
       if(v.getId() == R.id.btn_cy) {
           view.setBackgroundResource(R.drawable.shape_cy);
       } else if(v.getId() == R.id.btn_sq) {
           view.setBackgroundResource(R.drawable.shape_sq);
       }
    }
}